package com.zijiebutiao.mapper;

import com.zijiebutiao.pojos.TOrder;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

/**
* @author ZhangQingTian
* @description 针对表【t_order】的数据库操作Mapper
* @createDate 2023-03-06 09:52:22
* @Entity com.zijiebutiao.pojos.TOrder
*/
@Repository
public interface TOrderMapper extends BaseMapper<TOrder> {
    @Select("select count(*) from t_order where  orderDate = CURDATE()")
    Long todayNewOrder();
    @Select("select count(*) from t_order where orderDate between SUBDATE(CURDATE(),DATE_FORMAT(CURDATE(),'%w')-1) and SUBDATE(CURDATE(),DATE_FORMAT(CURDATE(),'%w')-7)")
    Long weekNewOrder();
    @Select("select count(*) from t_order where orderDate between DATE_ADD(CURDATE(),INTERVAL -DAY(CURDATE())+1 DAY) and LAST_DAY(CURDATE())")
    Long monthNewOrder();
    @Select("select count(*) from t_order where orderDate = CURDATE() and orderStatus='到诊'")
    Long todayNewOrderConfirm();
    @Select("select count(*) from t_order where orderDate between SUBDATE(CURDATE(),DATE_FORMAT(CURDATE(),'%w')-1) and SUBDATE(CURDATE(),DATE_FORMAT(CURDATE(),'%w')-7) and orderStatus='到诊'")
    Long weekNewOrderConfirm();
    @Select("select count(*) from t_order where orderDate between DATE_ADD(CURDATE(),INTERVAL -DAY(CURDATE())+1 DAY) and LAST_DAY(CURDATE()) and orderStatus='到诊'")
    Long monthNewOrderConfirm();
}




